 export function formatTimestamp(timestamp) {
    const now = Date.now();
    const diffInSeconds = Math.floor((now - timestamp) / 1000);
    
    // 如果时间戳是未来的时间，或者超过3个月，返回null
    if (diffInSeconds < 0 || diffInSeconds > 3 * 30 * 24 * 60 * 60) {
        return null;
    }
    
    // 1分钟内
    if (diffInSeconds < 60) {
        return "1分钟";
    }
    
    // 1小时内
    const diffInMinutes = Math.floor(diffInSeconds / 60);
    if (diffInMinutes < 60) {
        return `${diffInMinutes}分钟`;
    }
    
    // 1天内
    const diffInHours = Math.floor(diffInMinutes / 60);
    if (diffInHours < 24) {
        return `${diffInHours}小时`;
    }
    
    // 1月内（按30天算）
    const diffInDays = Math.floor(diffInHours / 24);
    if (diffInDays < 30) {
        return `${diffInDays}天`;
    }
    
    // 3月内
    const diffInMonths = Math.floor(diffInDays / 30);
    if (diffInMonths <= 3) {
        return `${diffInMonths}个月`;
    }
    
    // 理论上不会执行到这里，因为前面已经处理了超过3个月的情况
    return null;
}

